home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Developers / ABox.v1.8 / Header Files / ABox.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-23  |  14.0 KB  |  437 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABox.h
  15.  
  16. NAME
  17.     ABox.h, part of the ABox project source code
  18.     responsible for handling the AboutBox stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                netromancr@aol.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <netromancr@aol.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     10 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     10-mar-95    -    ty    -    1.2 clean up edits for universal headers under CW5.5
  38.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  39.                             release and the associated Universal Headers from Apple:
  40.                             most methods that returned references now have "Ref" at
  41.                             the end of their methods names to prevent possible collisions
  42.                             with datatypes and classes of the same name (older versions
  43.                             of the compiler didn't have a problem with this).
  44. */
  45.  
  46. /*===========================================================================*/
  47.  
  48. /*========== Exclusion Macros ============*/
  49.  
  50. #pragma    once
  51.  
  52. #ifndef    _ABox_
  53. #define    _ABox_
  54.  
  55.  
  56. /*============ Header Files ==============*/
  57.  
  58.  
  59.  
  60. #include    "ABObject.h"
  61. #include    "ABTopicList.h"
  62.  
  63. #include    "ABUControls.h"
  64. #include    "ABUTextBox.h"
  65. #include    "ABUString.h"
  66. #include    "ABUFonts.h"
  67.  
  68. //    if you define the SPEAK_ERROR symbol,
  69. //    the abox will speak any error messages; if you
  70. //    don't, it'll just beep it's little heart out.
  71.  
  72. #define    SPEAK_ERROR 1
  73.  
  74. #if    SPEAK_ERROR
  75. #include    "ABUEnvSpeechSynth.h"
  76.  
  77. #define    ABERR(pascalString)    { SysBeep(1); if (ABUEnvSpeechSynth::IsPresent()) SpeakString(pascalString);}
  78. #else
  79. #define    ABERR(pascalString) SysBeep(1)
  80. #endif    // SPEAK_ERROR
  81.  
  82.  
  83. /*=========== External Linkage ===========*/
  84.  
  85. /*================ Macros ================*/
  86.  
  87. /*============== Constants ===============*/
  88.  
  89. #define    kABoxWindow                    'ABWn'
  90. #define    kABoxWindowSize                (sizeof(WindowPtr))
  91.  
  92. #define    kABoxHomeFolder                'ABhf'
  93. #define    kABoxHomeFolderSize            (sizeof(FSSpec))
  94.  
  95. #define    kABoxSplashTimeSeconds        'ABst'
  96. typedef    long                        ABoxSplashTimeType;
  97. #define    kABoxSplashTimeSecondsSize    (sizeof(ABoxSplashTimeType))
  98. #define    kABoxNoSplash                    (0)
  99. #define    kABoxWaitForClickSplash            (-1)
  100. #define    kABoxWaitForApplicationSplash    (-2)
  101.  
  102. #define    kABoxNumberOfTopics            'ABNt'
  103. #define    kABoxNumberOfTopicsSize        (sizeof(ABListCount))
  104.  
  105. #define    kABoxFirstTopicNumber        'ABft'
  106. #define    kABoxFirstTopicNumberSize    (sizeof(ABIndex))
  107.  
  108. #define    kABoxCurrentTopic            'ABct'
  109. #define    kABoxCurrentTopicSize        (sizeof(ABTopic))
  110.  
  111. #define    kABoxFirstSlideNumber        'ABfs'
  112. #define    kABoxFirstSlideNumberSize    (sizeof(ABIndex))
  113.  
  114. #define    kABoxAppResFile                'ABrf'
  115. #define    kABoxAppResFileSize            (sizeof(short))
  116.  
  117. #define    kABoxUpdater                'ABup'
  118. #define    kABoxUpdaterSize            (sizeof(UpdateWindowUPP))
  119.  
  120. #define    kABoxModalIndicator            'ABmi'
  121. typedef enum _ABoxModalIndicator
  122. {
  123.     kABoxModal,
  124.     kABoxMoveableModal,
  125.     kABoxModeless
  126. } ABoxModalIndicator;
  127. #define    kABoxModalIndicatorSize        (sizeof(ABoxModalIndicator))
  128.  
  129. #define    kABoxAppNameAndVersion        'ABnv'
  130. #define    kABoxAppNameAndVersionRefSize    (sizeof(Str255))
  131.  
  132. #define    kABoxTextFont                'ABxf'
  133. typedef    short                        ABoxTextFontType;
  134. #define    kABoxTextFontSize            (sizeof(ABoxTextFontType))
  135.  
  136. #define    kABoxTextSize                'ABxs'
  137. typedef    short                        ABoxTextSizeType;
  138. #define    kABoxTextSizeSize            (sizeof(ABoxTextSizeType))
  139.  
  140. #define    kABoxTextFace                'ABxc'
  141. typedef    short                        ABoxTextFaceType;
  142. #define    kABoxTextFaceSize            (sizeof(ABoxTextFaceType))
  143.  
  144.  
  145. #define    kABoxLastEvent                'ABev'
  146. #define    kABoxLastEventSize            (sizeof(EventRecord))
  147.  
  148.  
  149. #define    kABoxListHandle                'ABlh'
  150. #define    kABoxListHandleSize            (sizeof(ListHandle))
  151.  
  152. #define    kABoxWindowTitle            'ABti'
  153. #define    kABoxWindowTitleSize        (sizeof(Str255))
  154.  
  155. #define    kABoxThreadsHandler            'ABTh'
  156. #define    kABoxThreadsHandlerSize        (sizeof(DoThreadsUPP))
  157.  
  158. #define    kABoxInBackground            'ABbg'
  159. #define    kABoxInBackgroundSize        (sizeof(Boolean))
  160.  
  161. #define    kABoxIsFinished                'ABIf'
  162. #define    kABoxIsFinishedSize            (sizeof(Boolean))
  163.  
  164. #define    kABoxReportMemory            'ABrm'
  165. #define    kABoxReportMemorySize        (sizeof(Boolean))
  166.  
  167. #define    kABoxUseSpeechMgr            'ABsm'
  168. #define    kABoxUseSpeechMgrSize        (sizeof(Boolean))
  169.  
  170. #define    kABoxUseDragMgr                'ABdm'
  171. #define    kABoxUseDragMgrSize            (sizeof(Boolean))
  172.  
  173. #define    kABoxUseSoundMgr            'ABzm'
  174. #define    kABoxUseSoundMgrSize        (sizeof(Boolean))
  175.  
  176.  
  177. #define    kAboutBoxWindowKind            (5001)
  178.  
  179. /*================ Enums =================*/
  180.  
  181. /*=============== Structs ================*/
  182.  
  183. /*=============== Typedefs ===============*/
  184.  
  185. //    d26    -    ty
  186. //    used for dispatching the update to another somebody...
  187. //
  188. //    WindowUpdateProcPtr is a pointer to a function that can handle
  189. //    Update events for a given window. This is useful, and indeed is
  190. //    necessary, for handling the updating of other windows (not ours)
  191. //    during ModalDialog event processing and Baloon Help.
  192. //
  193. typedef    void (*WindowUpdateProcPtr)(WindowPtr window);
  194.  
  195. #if GENERATINGCFM
  196.     // powerpc stuff
  197.     typedef UniversalProcPtr UpdateWindowUPP;
  198. #else
  199.     typedef WindowUpdateProcPtr UpdateWindowUPP;
  200. #endif
  201.  
  202. #define        kABbadUpdateWindowUPP            ((UpdateWindowUPP)NULL)
  203.  
  204. //    there is no RESULT_SIZE in the following UPP enumeration
  205. //    since the WindowUpdateProcPtr is a void function
  206. enum {
  207.     windowUpdateProcInfo = kCStackBased
  208.         |    STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr)))
  209. };
  210.  
  211. //    if USEROUTINEDESCRIPTORS is defined by the environment then universal
  212. //    proc ptr's will be generated in anticipation of possible PPC execution,
  213. //    otherwise all of the following defines and typedefs become the good
  214. //    old familiar 68k style information from pre-PowerMac days.
  215. //
  216. //    CallWindowUpdateProc() is a macro used to invoke the WindowUpdateProcPtr
  217. //    (UpdateWindowUPP) via univesral proc pointers.
  218. //
  219. //    NewWindowUpdateProc() is a macro used to dynamically create a
  220. //    universal WindowUpdateProcPtr (UpdateWindowUPP)
  221. //
  222. #if    GENERATINGCFM
  223.     //    powerpc stuff
  224.     #define NewWindowUpdateProc(userRoutine)        \
  225.             (UpdateWindowUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), windowUpdateProcInfo, GetCurrentISA())
  226.             
  227. #else        //    not using the universal PPC style proc pointers
  228.  
  229.     #define NewWindowUpdateProc(userRoutine)        \
  230.             (UpdateWindowUPP)(userRoutine)
  231.         
  232. #endif    //    GENERATINGCFM
  233.  
  234.  
  235. #if    GENERATINGCFM
  236.     #define CallWindowUpdateProc(userRoutine, windowPtr)        \
  237.             CallUniversalProc((UniversalProcPtr)(userRoutine), windowUpdateProcInfo, (windowPtr))
  238.     
  239. #else        //    not using the universal PPC style proc pointers
  240.  
  241.     #define CallWindowUpdateProc(userRoutine, windowPtr)        \
  242.             (*(userRoutine))((windowPtr))
  243. #endif    //    GENERATINGCFM
  244.  
  245.  
  246. //=============
  247.  
  248. //    used for yielding time to other threads...
  249. //
  250. //    DoThreadsProcPtr is a pointer to a Pascal-style parameter-less function 
  251. //    that returns a type of OSErr. It will be used as a means to
  252. //    handle yielding time to other threads, whether via the thread mgr or
  253. //    the older and not-really-supported threads pkg.
  254. //
  255. typedef    pascal OSErr (*DoThreadsProcPtr)(void);
  256.  
  257. #if    GENERATINGCFM
  258.     typedef    UniversalProcPtr    DoThreadsUPP;
  259. #else        //    not using the universal PPC style proc pointers
  260.  
  261.     typedef DoThreadsProcPtr     DoThreadsUPP;
  262.  
  263. #endif    //    GENERATINGCFM
  264.  
  265. //    there is no RESULT_SIZE in the following UPP enumeration
  266. //    since the DoThreadsProcPtr is a void function
  267. //
  268. //    there are no parameters in the following UPP enumeration since
  269. //    the DoThreadsProcPtr has none.
  270. enum {
  271.     doThreadsProcPtrInfo = kPascalStackBased
  272.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  273. };
  274.  
  275. //    if GENERATINGCFM is defined by the environment then universal
  276. //    proc ptr's will be generated in anticipation of possible PPC execution,
  277. //    otherwise all of the following defines and typedefs become the good
  278. //    old familiar 68k style information from pre-PowerMac days.
  279. //
  280. //    CallDoThreadsUpdateProc() is a macro used to invoke the DoThreadsProcPtr
  281. //    via univesral proc pointers.
  282. //
  283. //    NewDoThreadsProc() is a macro used to dynamically create a
  284. //    universal DoThreadsProcPtr
  285. //
  286. #if    GENERATINGCFM
  287. #define NewDoThreadsProc(userRoutine)        \
  288.         (UpdateWindowUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), doThreadsProcPtrInfo, GetCurrentISA())
  289.         
  290. #else        //    not using the universal PPC style proc pointers
  291.  
  292. #define NewDoThreadsProc(userRoutine)        \
  293.                 (DoThreadsUPP)(userRoutine)
  294.         
  295. #endif    //    GENERATINGCFM
  296.  
  297. #if    GENERATINGCFM
  298. #define CallDoThreadsUpdateProc(userRoutine)        \
  299.         CallUniversalProc((UniversalProcPtr)(userRoutine), doThreadsProcPtrInfo)
  300.  
  301. #else        //    not using the universal PPC style proc pointers
  302.  
  303. #define CallDoThreadsUpdateProc(userRoutine)        \
  304.                 (*(userRoutine))()
  305.         
  306. #endif    //    GENERATINGCFM
  307.  
  308.  
  309.  
  310. /*=========== Class Definitions ==========*/
  311.  
  312. #define    kABoxSuperProperty    ABObject
  313. class    ABox : public ABObject, 
  314.                 ABUControls
  315. #ifdef    SPEAK_ERROR
  316.             , ABUEnvSpeechSynth
  317. #endif    // SPEAK_ERROR
  318. {
  319.     public:
  320.                         ABox(void);
  321.         virtual            ~ABox(void);
  322.     
  323.             OSErr    GetProperty (ABProperty prop, void *ptr, long *ptrSize);
  324.             OSErr    SetProperty (ABProperty prop, void *ptr, long ptrSize);
  325.         
  326.             OSErr    Draw(WindowPtr window);
  327.             OSErr    Update(WindowPtr window);
  328.             Boolean    Event(EventRecord *event);
  329.             OSErr    Stop(void);
  330.             OSErr    Close(void);
  331.  
  332.             GrafPtr    GetWindow(void) const { return this->OurWindowRef(); }
  333.  
  334.             Boolean    IsInBackground(void) const { return this->InBackgroundFlagRef() == true; }
  335.             Boolean IsInForeground(void) const { return ! this->IsInBackground(); }
  336.             
  337.             Boolean    HasWindowNameRef(void) const { return this->WindowNameRef() != NULL; }
  338.             Boolean DoesntHaveWindowNameRef(void) const { return ! this->HasWindowNameRef(); }
  339.             
  340.             Boolean IsWindowUp(void) const { return this->WindowUpFlagRef() == true; }
  341.             Boolean WindowIsUp(void) const { return this->IsWindowUp(); }
  342.             Boolean WindowIsntUp(void) const { return ! this->WindowIsUp(); }
  343.             
  344.             Boolean    IsModal(void) const { return this->ModalIndicatorRef() == kABoxModal; }
  345.             Boolean    IsMoveableModal(void) const { return this->ModalIndicatorRef() == kABoxMoveableModal; }
  346.             Boolean    IsModeless(void) const { return this->ModalIndicatorRef() == kABoxModeless; }
  347.             
  348.             Boolean IsNotSplashScreen(void) const { return this->SplashTimeRef() == kABoxNoSplash; }
  349.             Boolean    IsClickSplash(void) const { return this->SplashTimeRef() == kABoxWaitForClickSplash; }
  350.             Boolean IsApplicationSplash(void) const { return this->SplashTimeRef() == kABoxWaitForApplicationSplash; }
  351.             Boolean IsSplashScreen(void) const { return ! this->IsNotSplashScreen(); }
  352.             
  353.     protected:
  354.     static    pascal    void    DrawDialogItem(DialogPtr dialog, short itemNo);
  355.     static    pascal Boolean    ModalEventFilter(DialogPtr dialog, EventRecord *event, short *item);
  356.  
  357.             OSErr    ToForeground(void);
  358.             OSErr    ToBackground(void);
  359.             
  360.             OSErr    ChangeControls(void);
  361.             OSErr    BuildABox (void);
  362.             OSErr    CreateAndFillTopicList (void);
  363.             OSErr    ProcessItemHit (EventRecord *eventRec, short itemNo);
  364.             Boolean    Splash (EventRecord *eventRec);
  365.             Boolean    HandleEvent (EventRecord *eventRec, short itemNo);
  366.             OSErr    DoThreads(void);
  367.  
  368.             void    ReportMemory(void);
  369.             
  370.     private:
  371.         //    these elements are caller available properties...
  372.                 FSSpecPtr            mHomeFolder;
  373.                 ABIndex                mFirstTopic;
  374.                 ABIndex                mFirstSlide;
  375.                 long                mSplashTime;
  376.                 short                mCallerResFile;
  377.                 UpdateWindowUPP        mUpdater;
  378.                 ABoxModalIndicator    mModalIndicator;
  379.                 StringPtr            mAppNameAndVersionRef;
  380.                 StringPtr            mWindowName;
  381.                 short                mTextFont;
  382.                 short                mTextSize;
  383.                 short                mTextFace;
  384.                 ListHandle            mListHandle;
  385.                 EventRecord            mLastEvent;
  386.                 Boolean                mInBackgroundFlag;
  387.                 DoThreadsUPP        mThreadsHandler;
  388.                 Boolean                mReportMemoryFlag;
  389.                 Boolean                mUseSpeechMgrFlag;
  390.                 Boolean                mUseSoundMgrFlag;
  391.                 Boolean                mUseDragMgrFlag;
  392.                 
  393.         //    these elements are strictly internal items...
  394.                 short                mDialogID;
  395.                 ABTopicList*        mTopics;
  396.                 ABUEnv*                mThreadsInfo;
  397.                 Boolean                mWindowUpFlag;
  398.                 ModalFilterUPP        mModalUPP;
  399.                 
  400.                 FSSpecPtr&            HomeFolderRef(void) const { return this->mHomeFolder; }
  401.                 ABIndex&            FirstTopicRef(void) const { return this->mFirstTopic; }
  402.                 ABIndex&            FirstSlideRef(void) const { return this->mFirstSlide; }
  403.                 long&                SplashTimeRef(void) const { return this->mSplashTime; }
  404.                 short&                CallerResFileRef(void) const { return this->mCallerResFile; }
  405.                 UpdateWindowUPP&    UpdaterRef(void) const { return this->mUpdater; }
  406.                 ABoxModalIndicator&    ModalIndicatorRef(void) const { return this->mModalIndicator; }
  407.                 StringPtr&            AppNameAndVersionRef(void) const { return this->mAppNameAndVersionRef; }
  408.                 StringPtr&            WindowNameRef(void) const { return this->mWindowName; }
  409.                 short&                TextFaceRef(void) const { return this->mTextFace; }
  410.                 short&                TextFontRef(void) const { return this->mTextFont; }
  411.                 short&                TextSizeRef(void) const { return this->mTextSize; }
  412.                 ListHandle&            ListHandleRef(void) const { return this->mListHandle; }
  413.                 EventRecord&        LastEventRef(void) const { return this->mLastEvent; }
  414.                 Boolean&            InBackgroundFlagRef(void) const { return this->mInBackgroundFlag; }
  415.                 DoThreadsUPP&        ThreadsHandlerRef(void) const { return this->mThreadsHandler; }
  416.                 Boolean&            ReportMemoryFlagRef(void) const { return this->mReportMemoryFlag; }
  417.                 Boolean&            UseSpeechMgrFlagRef(void) const { return this->mUseSpeechMgrFlag; }
  418.                 Boolean&            UseSoundMgrFlagRef(void) const { return this->mUseSoundMgrFlag; }
  419.                 Boolean&            UseDragMgrFlagRef(void) const { return this->mUseDragMgrFlag; }
  420.                 
  421.                 short&                DialogIDRef(void) const { return this->mDialogID; }
  422.                 ABTopicList*&        TopicsRef(void) const { return this->mTopics; }
  423.                 GrafPtr&            WindowRef(void) const { return this->OurWindowRef(); }
  424.                 ABUEnv*&            ThreadsInfoRef(void) const { return this->mThreadsInfo; }
  425.                 Boolean&            WindowUpFlagRef(void) const { return this->mWindowUpFlag; }
  426.                 ModalFilterUPP&        ModalUPPRef(void) const { return this->mModalUPP; }
  427.                 
  428.                 
  429. };
  430.  
  431.  
  432. /*========== Function Prototypes =========*/
  433.  
  434.  
  435. #endif    // _ABox_
  436.  
  437.